<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <title>幸运乐翻天</title>
    <link href="/static/css/app.css?time=<%=System.currentTimeMillis()%>" rel="stylesheet">
</head>

<body>
<div id="app" class="bg">
    <jsp:include page="top.jsp"/>
    <div class="continer">
        <div class="me" id="me">
            <div class="content">
                <ul id="dataList" class="lists">

                </ul>
            </div>
            <!-- <router-view></router-view> -->
            <div class="loading-container" id="loadingd">
                <div class="loading">
                    <img width="24" height="24" src="/static/img/loading.gif">
                    <p class="desc">正在加载...</p>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/static/js/jquery-3.2.1.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="/static/js/home.js?time=<%=System.currentTimeMillis()%>" charset="utf-8"></script>
<script>
    $(function() {
        if(localStorage.user){
            var user = JSON.parse(localStorage.user);
            console.log(user);
            $.ajax({
                method: "POST",
                url: "/topfun/user/changeGoods",
                data: {userId: user.userId,token:user.token},
                success: function (result) {
                    var json = JSON.parse(result);
                    $('#loadingd').hide()
                    if(json.code === 0 ){
                        var changeGoods = JSON.parse(json.data) || [];
                        var html = '';
                        if(changeGoods.length){
                            changeGoods.forEach(function (value,index,array) {
                                var strStatus = '已发货';
                                html += '<li class="item" >'+
                                    '    <div class="img">'+
                                    '        <img src="'+value.image+'" >'+
                                    '    </div>'+
                                    '    <div class="text">'+
                                    '        <h3 class="name">'+value.name+'</h3>'+
                                    '        <div class="time">'+
                                    '            兑换时间:&nbsp;'+value.createTime+
                                    '        </div>'+
                                    '        <div class="status">'+
                                    '            当前状态:&nbsp;'+strStatus+
                                    '        </div>'+
                                    '    </div>'+
                                    '    <div class="oper">'+
                                    '        <a class="see" href="gift.html?goodsExtendIds='+value.goodsExtendIds+'">查看</a>'+
                                    '    </div>'+
                                    '</li>';
                            })
                            $('#dataList').html(html);
                        }else{
                            $('#dataList').html('<div class="tip">您还没有兑换物品呢</div>');
                        }


                    }else {//服务器错误信息
                        console.log(json.msg);
                    }
                }
            }).fail(function () {
                alert("$.ajax /topfun/user/changeGoods failed!");
            })
        }
    });
</script>
</body>

</html>
